package com.ruoyi.web.dorm.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.web.dorm.entity.AdminEntity;
import com.ruoyi.web.dorm.entity.StudentHealthEntity;
import com.ruoyi.web.dorm.service.AdminService;
import io.swagger.models.auth.In;
import org.apache.ibatis.annotations.Insert;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

@RestController
@RequestMapping("/dorm/admin")
public class AdminController extends BaseController {
    @Autowired
    private AdminService adminService;

    /**
     * 桌面 查询管理员个人信息
     * @param adminEntity
     * @return
     */
    @GetMapping("/tabAdminList")
    public TableDataInfo TabAdminList(AdminEntity adminEntity){
        return getDataTable(adminService.TabAdminList(adminEntity));
    }

    /**
     * 查询管理员列表信息
     * @param adminEntity
     * @return
     */
    @GetMapping("/getAdminList")
    public TableDataInfo getAdminList(AdminEntity adminEntity){
        startPage();
        return getDataTable(adminService.getAdminList(adminEntity));
    }



    /**
     * 添加学生卫生信息
     * @param adminEntity
     * @return
     */
    @PostMapping("/addAdminList")
    public AjaxResult addAdminList(@RequestBody AdminEntity adminEntity ){
        return toAjax(adminService.addAdminList(adminEntity));
    }

    /**
     * 更新管理员信息
     * @param adminEntity
     * @return
     */
    @PostMapping("/updateAdminList")
    public AjaxResult updateAdminList(@RequestBody AdminEntity adminEntity){
        return toAjax(adminService.updateAdminList(adminEntity));
    }

    /**
     * 假删除管理员信息
     * @param id
     * @return
     */
    @DeleteMapping("/delAdminList")
    public AjaxResult delAdminList(Long id){
        return toAjax(adminService.delAdminList(id));
    }



    /**
     * 查询管理员信息导出信息
     * @param adminEntity
     * @return
     */
    @GetMapping("/export")
    public void export(HttpServletResponse response, AdminEntity adminEntity) {
        List<AdminEntity> list = adminService.getAdminList(adminEntity);//导出数据
        ExcelUtil<AdminEntity> util = new ExcelUtil<>(AdminEntity.class);
        util.exportExcel(response,list,"管理员信息");
    }


}
